package com.example.service.impl;

import com.example.mapper.StudnetMapper;
import com.example.pojo.EmpQueryParam;
import com.example.pojo.PageResult;
import com.example.pojo.Student;
import com.example.pojo.StudentQueryParam;
import com.example.service.StudentService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * StudentServiceImpl 类的描述信息
 *
 * @author 12427
 * @since 2025/6/7 13:12
 */
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
  private StudnetMapper studnetMapper;

    /**
     *   分页查询学生
     */
    @Override
    public PageResult<Student> page(StudentQueryParam studentQueryParam) {
        PageHelper.startPage(studentQueryParam.getPage(),studentQueryParam.getPageSize());
//        查询
      List<Student> list= studnetMapper.list(studentQueryParam);
      Page<Student> p = (Page<Student>) list;
        return new PageResult<Student>(p.getTotal(),p.getResult());
    }
//删除学员
    @Override
    public void deletrById(List<Integer> ids) {
        studnetMapper.deleteById(ids);
    }
//  添加学院
    @Override
    public void input(Student student) {
        student.setCreateTime(LocalDateTime.now());
        student.setUpdateTime(LocalDateTime.now());
        studnetMapper.inst(student);
    }
//  根据ID查询学生
    @Override
    public Student getInfo(Integer id) {
        return studnetMapper.getINfo(id);
    }
//  修改学员
    @Override
    public void update(Student student) {
        student.setUpdateTime(LocalDateTime.now());
        studnetMapper.update(student);
    }
    //  危机扣分
    @Override
    public void updatesore(Integer id, Integer score) {
        studnetMapper.updatesore(id,score);
    }


}
